#include "FocusGainedHandler.h"

#ifdef __QT5_TARGET

#include <QtCore/QEvent>
#include <QtWidgets/QLineEdit>

#else

#include <QEvent>
#include <QLineEdit>

#endif

#include "NullPointerException.h"
FocusGainedHandler::FocusGainedHandler(void):QObject()
{
}

FocusGainedHandler::~FocusGainedHandler(void)
{
}

bool FocusGainedHandler::eventFilter(QObject *object, QEvent *event)
{
	if(event->type() == QEvent::FocusIn)
	{

		QLineEdit * box = dynamic_cast<QLineEdit*>(object);
		if(box == NULL)
		{
			NullPointerException NPE;
			NPE.setMessage("FocusGained EventFilter set to a wrong widget");
			throw NPE;
			return false;
		}
		box->clear();
		return true;
	}
	return QObject::eventFilter(object, event);
}